package com.yichen.codesandbox.factory;


import com.yichen.codesandbox.model.enums.CodeSandBoxTypeEnum;
import com.yichen.codesandbox.service.CodeSandBox;
import com.yichen.codesandbox.service.impl.ExampleCodeSandBox;
import com.yichen.codesandbox.service.impl.RemoteCodeSandBox;
import com.yichen.codesandbox.service.impl.ThirdPartyCodeSandBox;

/**
 * 代码沙箱工厂
 */
public class CodeSandBoxFactory {
    public static CodeSandBox getCodeSandBox(String type) {
        CodeSandBox codeSandBox = new ExampleCodeSandBox();
        CodeSandBoxTypeEnum enumByValue = CodeSandBoxTypeEnum.getEnumByValue(type);
        switch (enumByValue) {
            case ExamPleCodeSandBox:
                codeSandBox = new ExampleCodeSandBox();
                break;
            case RemoteCodeSandBox:
                codeSandBox = new RemoteCodeSandBox();
                break;
            case ThirdPartyCodeSandBox:
                codeSandBox = new ThirdPartyCodeSandBox();
                break;
            default:
                return codeSandBox;
        }
        return codeSandBox;
    }
}
